<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../../layuiadmin/style/admin.css" media="all">
</head>
<body>

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-form layui-card-header layuiadmin-card-header-auto" lay-filter="search_from">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">用户名</label>
                            <div class="layui-input-inline">
                                <input type="text" name="username" placeholder="请输入" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">状态</label>
                            <div class="layui-input-inline">
                                <script type="text/html" template lay-url="{{ layui.setter.apiHost }}/financial/seller_withdraw/get_status" lay-done="layui.form.render();">
                                    <select name="status">
                                        <option value=""></option>
                                        {{# layui.each(d.data, function(index, item){ }}
                                        <option value="{{ index }}">{{ item }}</option>
                                        {{# }); }}
                                    </select>
                                </script>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <button class="layui-btn layuiadmin-btn-list" lay-submit lay-filter="search_button">
                                <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                            </button>
                        </div>
                    </div>
                </div>

                <div class="layui-card-body">
                    <table id="table_list" lay-filter="table_list"></table>
                    <script type="text/html" id="action_button">
                        {{# if(d.status == 0){ }}
                        <a class="layui-btn layui-btn-xs" lay-event="agreed">同意</a>
                        <a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="refused_money">拒绝并退还资金</a>
                        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="refused_no_money">拒绝不退还资金</a>
                        {{# } }}
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="../../../layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '../../../layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table', 'helper'], function () {
        var admin = layui.admin,
            table = layui.table,
            form = layui.form,
            helper = layui.helper,
            api_action_url = layui.setter.apiHost + '/financial/seller_withdraw';

        //表格操作
        table.render({
            elem: '#table_list',
            url: api_action_url,
            toolbar: '#toolbar_tmp',
            cols: [[
                {type: 'checkbox', fixed: 'left'},
                {field: 'id', title: 'ID', width: 80},
                {field: 'username', title: '用户名', minWidth: 120},
                {field: 'amount', title: '提现金额', width: 120},
                {field: 'done_at', title: '完成时间', width: 170},
                {field: 'note', title: '备注', width: 150},
                {field: 'created_at', title: '创建时间', width: 170},
                {field: 'status_text', title: '状态', width: 150, fixed: 'right'},
                {title: '操作', width: 300, align: 'center', fixed: 'right', toolbar: '#action_button'}
            ]],
            page: true
        });

        //监听工具条操作按钮
        table.on('tool(table_list)', function (obj) {
            var data = obj.data;
            switch (obj.event) {
                case 'agreed':
                    helper.ajax(api_action_url + '/agreed', {id: data.id});
                    break;
                case 'refused_money':
                    layer.prompt({title: '请输入备注', formType: 2}, function (note, index) {
                        helper.ajax(api_action_url + '/refused_money', {id: data.id, note: note});
                        layer.close(index);
                    });
                    break;
                case 'refused_no_money':
                    layer.prompt({title: '请输入备注', formType: 2}, function (note, index) {
                        helper.ajax(api_action_url + '/refused_no_money', {id: data.id, note: note});
                        layer.close(index);
                    });
                    break;
            }
        });
    });
</script>
</body>
</html>